package com.example.educationplatformbackend.service.Impl;

import com.example.educationplatformbackend.domian.illustrations.Illustration;
import com.example.educationplatformbackend.mapper.IllustrationMapper;
import com.example.educationplatformbackend.service.IllustrationServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class IllustrationService implements IllustrationServiceImpl {


    @Autowired
    private IllustrationMapper illustrationMapper;

    public List<Illustration> getAllIllustrations() {
        return illustrationMapper.findAll();
    }

    public Illustration getIllustrationById(Long id) {
        return illustrationMapper.findById(id);
    }

    public void saveOrUpdate(Illustration illustration) {
        illustrationMapper.save(illustration);
    }

    @Override
    public void update(Illustration illustration) {
        System.out.println(illustration);
        illustrationMapper.updateIllustration(illustration);
    }

    public void deleteIllustration(Long id) {
        illustrationMapper.deleteById(id);
    }

}
